#ifndef __INTERRUPT_H__
#define __INTERRUPT_H__

#include  "stm32mp1xx_gpio.h"
#include "stm32mp1xx_rcc.h"
#include "stm32mp1xx_exti.h"
#include "stm32mp1xx_gic.h"
#include "gpio.h"

typedef enum{
    EXTI_FALLING = 0,
    EXTI_RISING,
}exti_trigger_t;//上升、下降沿
typedef enum{
    EXTI0_INPUT_EVENT = 0,
    EXTI1_INPUT_EVENT,
    EXTI2_INPUT_EVENT,
    EXTI3_INPUT_EVENT,
    EXTI4_INPUT_EVENT,
    EXTI5_INPUT_EVENT,
    EXTI6_INPUT_EVENT,
    EXTI7_INPUT_EVENT,
    EXTI8_INPUT_EVENT,
    EXTI9_INPUT_EVENT,
    EXTI10_INPUT_EVENT,
    EXTI11_INPUT_EVENT,
    EXTI12_INPUT_EVENT,
    EXTI13_INPUT_EVENT,
    EXTI14_INPUT_EVENT,
    EXTI15_INPUT_EVENT,
}input_event_t;

typedef enum {
    GPIOA_EXTI = 0,
    GPIOB_EXTI,
    GPIOC_EXTI,
    GPIOD_EXTI,
    GPIOE_EXTI,
    GPIOF_EXTI,
    GPIOG_EXTI,
    GPIOH_EXTI,
    GPIOI_EXTI,
    GPIOJ_EXTI,
    GPIOK_EXTI,
}gpio_exti_t;

#define  EXTI9_ID    99
#define  EXTI9_PRIORITY   5

#define  EXTI15_ID    159
#define  EXTI15_PRIORITY   5

#define  EXTI5_ID    55
#define  EXTI5_PRIORITY   5

#define  EXTI12_ID    108
#define  EXTI12_PRIORITY   5
void hal_gpio_IT_init(gpio_t *gpio, 
            unsigned int pins, gpio_mode_t mode);
void hal_exti_IT_init(unsigned int pins,
		gpio_exti_t exti,
		exti_trigger_t trigger,input_event_t event);
void hal_gic_IT_init(unsigned int irq_num,
		unsigned int priority);
void hal_clear_exti_IT(exti_trigger_t trigger,input_event_t event);
void hal_clear_gicc_IT(unsigned int irq_num);
#endif 
